<div navbar ng-init="currentItem='utils.network'"></div>
<div ng-show="!loaded">
    <div loading></div>
</div>

<div id="main" ng-show="loaded" style="display:none">
    <div class="module-header">
        <h3>网络设置</h3>
    </div>

    <div class="tabbable">
        <ul class="nav nav-tabs">
            <li ng-class="'active' | iftrue:activeTabName=='hostname'"><a href="#hostname" ng-click="sec('hostname')" data-toggle="tab">主机名</a></li>
            <li ng-class="'active' | iftrue:activeTabName=='ip'"><a href="#ip" ng-click="sec('ip')" data-toggle="tab">IP设置</a></li>
            <li ng-class="'active' | iftrue:activeTabName=='dns'"><a href="#dns" ng-click="sec('dns')" data-toggle="tab">DNS设置</a></li>
            <li ng-class="'active' | iftrue:activeTabName=='restart'"><a href="#restart" ng-click="sec('restart')" data-toggle="tab">重启网络</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane" ng-class="'active' | iftrue:activeTabName=='hostname'" id="hostname" ng-init="loadHostName()">
                <form class="form-horizontal form-horizontal-small" ng-submit="saveHostName()" onsubmit="return false">
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label" for="bind_hostname">主机名</label>
                        <div class="col-sm-10">
                            <input class="form-control" ng-model="hostname" ng-disabled="processing" type="text" id="bind_hostname" placeholder="服务器主机名">
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <button type="submit" class="btn btn-default" ng-disabled="processing">提交修改</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="tab-pane" ng-class="'active' | iftrue:activeTabName=='ip'" id="ip" ng-init="loadIP()">
                <div class="alert alert-warning">修改IP设置后，需要重启网络，配置才会生效。</div>
                <form class="form-horizontal form-horizontal-small" ng-submit="saveIfConfig()" onsubmit="return false">
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label">网络接口</label>
                        <div class="col-sm-10">
                            <div class="btn-group" ng-init="loadIfNames()">
                                <button type="button" class="btn btn-default" ng-class="'active'|iftrue:ifname==tifname" ng-click="loadIfConfig(tifname)" ng-repeat="tifname in ifnames">{{tifname}}</button>
                            </div>
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label" for="ip">IPv4地址</label>
                        <div class="col-sm-10">
                            <input class="form-control" ng-model="ip" ng-disabled="processing" type="text" id="ip" placeholder="IPv4地址">
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label" for="mask">子网掩码</label>
                        <div class="col-sm-10">
                            <input class="form-control" ng-model="mask" ng-disabled="processing" type="text" id="mask" placeholder="子网掩码">
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label" for="gw">默认网关</label>
                        <div class="col-sm-10">
                            <input class="form-control" ng-model="gw" ng-disabled="processing" type="text" id="gw" placeholder="默认网关">
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <button type="submit" class="btn btn-default" ng-disabled="processing">提交修改</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="tab-pane" ng-class="'active' | iftrue:activeTabName=='dns'" id="dns" ng-init="loadDNS()">
                <form class="form-horizontal form-horizontal-small" ng-submit="saveNameservers()" onsubmit="return false" ng-init="loadNameservers()">
                    <div class="form-group form-inline" ng-repeat="nameserver in nameservers">
                        <label class="col-sm-2 control-label">DNS {{$index+1}}：</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <input class="form-control nameserver" ng-disabled="processing" type="text" value="{{nameserver}}" placeholder="DNS 服务器地址">
                                <div class="input-group-btn">
                                    <button type="button" class="btn btn-default" ng-disabled="processing" ng-click="delNameserver($index)"><i class="glyphicon glyphicon-minus"></i></button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label">DNS 服务器</label>
                        <div class="col-sm-10">
                            <button type="button" class="btn btn-default" ng-disabled="processing" ng-click="addNameserver()"><i class="glyphicon glyphicon-plus"></i> 增加 DNS 服务器</button>
                        </div>
                    </div>
                    <div class="form-group form-inline">
                        <label class="col-sm-2 control-label"></label>
                        <div class="col-sm-10">
                            <button type="submit" class="btn btn-default" ng-disabled="processing">提交修改</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="tab-pane" ng-class="'active' | iftrue:activeTabName=='restart'" id="restart" ng-init="restartService()">
                <div class="well">
                    <p><span ng-bind-html-unsafe="restartMessage"></span></p>
                    <p style="display:none;margin-top:20px" ng-show="showRestartBtn">
                        <button class="btn btn-default" ng-click="restart()" ng-disabled="processing">确定并重启网络</button>
                    </p>
                </div>
            </div>
        </div>
    </div>

</div>